#ifndef __PID_INC_H__
#define __PID_INC_H__

#include "plat/nonecopyable.h"

/// @brief 增量式PID
class PID_Inc : public NoneCopyable
{
public:
    explicit PID_Inc();
    explicit PID_Inc(float p, float i, float d);
    virtual ~PID_Inc();

public:
    float Compute(float tar,float act);
    void SetPid(float p, float i, float d);

    void SetOutputLimitsEnabled(bool enabled); 
    void SetOutputLimits(float min, float max); 

    float GetKp();
    float GetKi();
    float GetKd();		

private:
    void Limit(float &val);

private:
    float kp = 0;
    float ki = 0;
    float kd = 0;
    float target = 0;
    float actual = 0;
    float e = 0;
    float e_pre_1 = 0; //pre
    float e_pre_2 = 0; //pre_pre

    float A = 0;
    float B = 0;
    float C = 0;

    bool m_outLimitsEnabled = false;
    float m_outMin = 0;
    float m_outMax = 0;
};

#endif // __PID_INC_H__
